<?php
if (! defined ( 'BASEPATH' )) {
	exit ( 'No direct script access allowed' );
}

/*
 *公共方法
 *@author 
 */
class public_view extends CI_Controller {
	function __construct() {
		parent::__construct ();
		$this->load->helper ( 'url' );
		$this->load->library ( 'code_fragment' );
		$this->load->model ( 'user_model' );
	}
	function delePersonalInfo($table,$deleFlag=1){
		$array['deleFlag']=$deleFlag;
		$array['deleTime']=date('Y-m-d H:i:s');
		$array['id']=$_POST["id"];
		//log_message("info","user Array" .json_encode($array));
		$code=$this->user_model->updatePersonalInfo($array,$table);
		echo ($code>0)?"操作成功":"系统繁忙请稍后再试";
	}
	function userDynamic() {
		$this->load->view ( 'public_view/user_dynamic' );
	}
	function userLeft() {
		$this->load->view ( 'public_view/user_left' );
	}
	function userOptDynamic($type) {
		
		$this->load->view ( 'public_view/user_hytj', $this->code_fragment->getUserOptDynamicCode ( $type ) );
	}
	function userOptDynamicData($type){
		$data='';
		if($type=='remind'){
			$this->load->model('theirwishes_model');
			$data=$this->theirwishes_model->getAllFriendBirthiday($this->session->userdata("userId"),10);
		}else if($type=='dynamic') {
			$this->load->model("user_dynamic/user_dynamic_model");
			$data=$this->user_dynamic_model->queryFriendsList($this->session->userdata("userId"));
			//$data=$this->code_fragment->getUserOptDynamicCode ( $type ,$data) ;
		}elseif($type=="yearbook"){
			$this->load->model("user_model");
			$data=$this->user_model->getTeamInfo(array("userId"=>$this->session->userdata("userId")));
			//$data=$this->code_fragment->getUserOptDynamicCode ( $type ,$data);
		}
		$data=$this->code_fragment->getUserOptDynamicCode ( $type ,$data) ;
		$this->load->view ( 'public_view/user_hytj', $data);
	}
	function userShowDynamic($type = 'yearbook', $yearbookRelegation = 1, $yearbookType = 0, $limit = 2, $offset = 1) {
		$divCode = "";
		switch ($type) {
			case 'yearbook' :
				$divCode = $this->getYearBookInfo ( $yearbookRelegation, $yearbookType, $limit, $offset );
				break;
		}
		$this->load->view ( 'public_view/user_show_dynamic_info', array ("divCode" => $divCode ) );
	}
	
	function dialog() {
		$this->load->view ( 'public_view/dialog', $_POST );
	}
	function getYearBookInfo($yearbookRelegation = 2, $yearbookType = 1, $limit = 2, $offset = 1) {
		
		$this->load->library ( 'code_fragment' );
		$this->load->model ( 'yearbook_model' );
		$rs = $this->yearbook_model->queryPersonalYearbook ( array ('yearbookRelegation' => $yearbookRelegation, 'yearbookType' => $yearbookType ), $limit, $offset );
		log_message ( "info", json_encode ( $rs ) );
		$divCode = "";
		foreach ( $rs as $result ) {
			log_message ( "info", "testData" . json_encode ( $result ) );
			$divCode .= $this->code_fragment->yearbookTag ( $result );
		}
		$this->load->view ( 'public_view/user_show_dynamic_info', array ("divCode" => $divCode ) );
	}
	function userTjQzf() {
	
	}
	function window($type = 'qzf', $accepterId = '', $userId = '') {
		$array = array ();
		//"qzf" => array ("title" => "群祝福", "controller" => "user/userDynamicAdd/qzf" ), "morePic" => array ("title" => "图片上传", "controller" => "user/photowall/addPhontowall" ) 
		switch ($type) {
			case 'qzf' :
				$assceptTag = $this->user_model->getUserNameDelTag ( array ("Id" => $accepterId ) );
				$userTag = $this->user_model->getUserNameDelTag ( array ("Id" => $userId ) );
				$divCode = $this->code_fragment->windowQzf ( $userTag, $assceptTag );
				$array = array ("divCode" => $divCode, "title" => "群祝福", "controller" => "user/userDynamicAdd/qzf", "type" => $type );
				break;
			case 'morePic' :
				$divCode = $this->code_fragment->windowPhotowall ();
				$array = array ("title" => "图片上传", "controller" => "user/userDynamicAdd/photowall", "type" => $type, "divCode" => $divCode );
				break;
		}
		
		$this->load->view ( "public_view/window", $array );
	}
	function userIcon() {
		//echo '$("#user_content").append("<div class=cont_tplf_img></div>");';
	}
	function userDynamicAdd($type = 'text') {
		$divCode=array("divCode"=>"系统繁忙，请稍后");
		switch ($type) {
			case 'text' :
				$divCode=$this->code_fragment->userDynamicText ();
				break;
			case 'link' :
				$divCode=$this->code_fragment->userDynamicLink ();
				break;
			case 'vedio' :
				$divCode=$this->code_fragment->userDynamicVideo();
				break;
			case 'image' :
				$divCode=$this->code_fragment->userDynamicImage ();
				break;
		
		}
		log_message("info","divCode link==>".json_encode($divCode));
		$this->load->view("public_view/add_dynamic",array("divCode"=>$divCode['divCode'],'user_model_js'=>"<link href='".base_url()."assets/css/face/face.css' rel='stylesheet' type='text/css' /><script src='".base_url()."assets/js/grzy/dynamic_add.js' type='text/javascript'></script>","user_model_js_function"=>"dynamicAddInit('".base_url()."index.php/');".$divCode["jsCode"].""));
		
	}
	function playVideo() {
		$this->load->view ( "public_view/video", array ("videoUrl" =>"http://player.youku.com/player.php/sid/XNTY0ODc3MDc2/v.swf", "imageUrl" =>"http://g2.ykimg.com/11270F1F4651A901913D8B0123193CB35CF3BD-740E-C1F6-A3FF-E45A51C01B04" ) );
	}
	function dropDown() {
		$this->load->view ( "test/dropDown" );
	}
	function showEdit(){
		$this->load->view("test/edit");
	}
	function photowall() {
		$this->load->model ( "photowall_model" );
		$array = $this->photowall_model->queryPersonalYearbook ( array (), 20, 1 );
		$data ['result'] = json_encode ( $array );
		$this->load->view ( "public_view/photowall", $data );
	}
	function  getFlashInfo(){
		$this->load->library("VideoUrlParser");
		$data = $this->input->post('flashUrl');
		$result['data'] = VideoUrlParser::parse($data);
		log_message("info",json_encode($result['data']));
		echo json_encode($result['data']);
	}
}
?>